package com.cat.singleton.demo01;

/**
 * 双重锁检查
 *
 * @author cat
 * @version 2025/5/15 16:49
 * @since JDK17
 */

public class Singleton03 {
    private Singleton03() {
    }

    private static volatile Singleton03 instance;

    public static Singleton03 getInstance() {
        // 双重锁检查
        if (instance == null) {
            synchronized (Singleton03.class) {
                if (instance == null) {
                    instance = new Singleton03();
                }
            }
        }
        return instance;
    }

}
